{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Demonstrating Matplotlib Modin Interoperability"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import modin.pandas as pd\n",
    "import pandas\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with Modin df\n",
    "# Example modified from https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/xcorr_acorr_demo.html#sphx-glr-gallery-lines-bars-and-markers-xcorr-acorr-demo-py\n",
    "\n",
    "# Fixing random state for reproducibility\n",
    "np.random.seed(19680801)\n",
    "\n",
    "x = pd.DataFrame(np.random.randn(100, 1),columns=[\"Col_1\"])\n",
    "y = pd.DataFrame(np.random.randn(100, 1),columns=[\"Col_1\"])\n",
    "\n",
    "fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)\n",
    "ax1.xcorr(x[\"Col_1\"], y[\"Col_1\"], usevlines=True, maxlags=50, normed=True, lw=2)\n",
    "ax1.grid(True)\n",
    "\n",
    "ax2.acorr(x[\"Col_1\"], usevlines=True, normed=True, maxlags=50, lw=2)\n",
    "ax2.grid(True)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with pandas df\n",
    "# Example modified from https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/xcorr_acorr_demo.html#sphx-glr-gallery-lines-bars-and-markers-xcorr-acorr-demo-py\n",
    "\n",
    "# Fixing random state for reproducibility\n",
    "np.random.seed(19680801)\n",
    "\n",
    "x = pandas.DataFrame(np.random.randn(100, 1),columns=[\"Col_1\"])\n",
    "y = pandas.DataFrame(np.random.randn(100, 1),columns=[\"Col_1\"])\n",
    "\n",
    "fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)\n",
    "ax1.xcorr(x[\"Col_1\"], y[\"Col_1\"], usevlines=True, maxlags=50, normed=True, lw=2)\n",
    "ax1.grid(True)\n",
    "\n",
    "ax2.acorr(x[\"Col_1\"], usevlines=True, normed=True, maxlags=50, lw=2)\n",
    "ax2.grid(True)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with Modin df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.bar(modin_df['names'], modin_df['values'])\n",
    "plt.subplot(132)\n",
    "#plt.scatter(df['names'], df['values'])\n",
    "#plt.subplot(133)\n",
    "plt.plot(modin_df['names'], modin_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with pandas df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.bar(pandas_df['names'], pandas_df['values'])\n",
    "plt.subplot(132)\n",
    "\n",
    "plt.plot(pandas_df['names'], pandas_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with Modin df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.barh(modin_df['names'], modin_df['values'])\n",
    "plt.subplot(132)\n",
    "#plt.scatter(df['names'], df['values'])\n",
    "#plt.subplot(133)\n",
    "plt.plot(modin_df['names'], modin_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with pandas df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.barh(pandas_df['names'], pandas_df['values'])\n",
    "plt.subplot(132)\n",
    "plt.plot(pandas_df['names'], pandas_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.hlines(pandas_df['values'], 1, 3)\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with Modin df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.bar(modin_df['names'], modin_df['values'])\n",
    "plt.subplot(132)\n",
    "#plt.scatter(df['names'], df['values'])\n",
    "#plt.subplot(133)\n",
    "plt.plot(modin_df['names'], modin_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a visualization with pandas df\n",
    "# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py\n",
    "\n",
    "names = ['group_a', 'group_b', 'group_c']\n",
    "values = [1, 10, 100]\n",
    "\n",
    "pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})\n",
    "\n",
    "plt.figure(figsize=(9, 3))\n",
    "\n",
    "plt.subplot(131)\n",
    "plt.bar(pandas_df['names'], pandas_df['values'])\n",
    "plt.subplot(132)\n",
    "#plt.scatter(df['names'], df['values'])\n",
    "#plt.subplot(133)\n",
    "plt.plot(pandas_df['names'], pandas_df['values'])\n",
    "plt.suptitle('Categorical Plotting')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
  },
  "kernelspec": {
   "display_name": "Python 3.9.10 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
